package com.ccb.sc.member.convert;

import com.ccb.sc.member.vo.AppMemberUpdateVo;
import com.ccb.sc.member.vo.AppMemberVo;
import com.ccb.sc.common.modules.member.entity.Member;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import static org.mapstruct.factory.Mappers.getMapper;

/**
 * @author ken
 * @version 1.0
 * @date 2020-09-16
 */
@Mapper
public interface AppMemberConvert {

    AppMemberConvert INSTANCE = getMapper(AppMemberConvert.class);

    /**
     * 实体转vo
     * @param member 实体
     * @return vo
     */
    AppMemberVo entityToVo(Member member);

    @Mapping(target = "gender", expression = "java(com.ccb.sc.common.enums.Gender.getByValue(updateVo.getGender()))")
    Member updateVo2Entity(AppMemberUpdateVo updateVo);
}
